package cn.js.ccit.service.impl;

import cn.js.ccit.entity.Branch;
import cn.js.ccit.mapper.BranchMapper;
import cn.js.ccit.service.BranchService;
import cn.js.ccit.utils.MyBatisUtils;

import java.util.List;

public class BranchServiceImpl implements BranchService {

    BranchMapper branchMapper = MyBatisUtils.getSession().getMapper(BranchMapper.class);
    @Override
    public List<Branch> getBranchBy(Branch branch) {
        return branchMapper.getBranchBy(branch);
    }

    @Override
    public Branch getBranchById(Integer branchId) {
        return branchMapper.getBranchById(branchId);
    }

    @Override
    public boolean isExist(Branch branch) {
        List<Branch> branchList = branchMapper.getBranchBy(branch);
        if(branchList!=null && branchList.size()>0){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public boolean addBranch(Branch branch) {
        return branchMapper.addBranchBy(branch);
    }

    @Override
    public boolean deleteBranchById(Integer branchId) {
         branchMapper.deleteBranchById(branchId);
         return true;
    }
}
